package org.springcloud.wisdom.springcloud_03_freshman.student.controller;

import org.springcloud.wisdom.springcloud_03_freshman.common.bean.ResponseData;
import org.springcloud.wisdom.springcloud_03_freshman.common.controller.BaseController;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Goods;
import org.springcloud.wisdom.springcloud_03_freshman.student.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/goods")
public class GoodsController extends BaseController {
    @Autowired
    GoodsService goodsService;

    /**
     * 根据学号来获取物品记录
     * @param sid 学号
     * @return
     */
    @GetMapping("/get")
    public ResponseData<Object> getGoodsBySid(@RequestParam("sid") String sid){
        return returnObject(goodsService.getGoods(sid));
    }

    /**
     * 根据sid来更新学生是否领取了物品
     * @param sid
     * @return
     */
    @RequestMapping("/update")
    public ResponseData<Object> updateGoodsBySid(@RequestParam("sid") String sid){
        Goods goods=new Goods();
        goods.setSid(sid);
        return returnObject(goodsService.updateGoods(goods));
    }
}
